package Others.DesignPattern.ObserverPattern.Original;


import Others.DesignPattern.ObserverPattern.Pattern.Object.*;

public class main {
    public static void main(String[] args) {
        //观察者模式

        Secretary proscenium = new Proscenium();

        Observer colleagueA = new ColleagueA("小A", proscenium);
        Observer colleagueB = new ColleagueA("小B", proscenium);

        proscenium.AddObserver(colleagueA);
        proscenium.AddObserver(colleagueB);

        proscenium.setMessage("老板回来了！");

        proscenium.NotifyObserver();

        System.out.println();

        Boss boss = new Boss();
        boss.setMessage("我来看看谁在摸鱼！");

        Observer 小A = new ColleagueA("小A", boss);
        Observer 小B = new ColleagueB("小A", boss);

        boss.AddObserver(小A);
        boss.AddObserver(小B);

        boss.DropObserver(小B);//小B发现老板回来了,所以本质上没有被老板通知！

        boss.NotifyObserver();



    }
}
